import { defineStore } from 'pinia';
import { ref } from 'vue';
import axios from 'axios';

export const useLargeScreenStore = defineStore('largeScreen', () => {
  const layout = ref([]);
  
  const loadLayout = async () => {
    try {
      // 从后端加载布局配置
      const response = await axios.get('/api/screen/layout');
      layout.value = response.data;
    } catch (error) {
      console.error('加载布局失败:', error);
    }
  };
  
  const saveLayout = async (newLayout: any[]) => {
    try {
      // 保存布局配置到后端
      await axios.post('/api/screen/layout', newLayout);
      layout.value = newLayout;
    } catch (error) {
      console.error('保存布局失败:', error);
    }
  };
  
  return {
    layout,
    loadLayout,
    saveLayout
  };
}); 